<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"> 
    <ui:composition template="index.xhtml">
        <ui:define name="body">

            <h:form>
                <div id="breadcrumb">
                    <p:commandLink  value="Inicio" update="@form" actionListener="#{managerRedirect.redirect('index.xhtml')}" immediate="true"/> >
                    <p:commandLink  value="Configurações" update="@form" actionListener="#{managerRedirect.redirect('configuration.xhtml')}" immediate="true"/> >
                    <p:commandLink  value="Orgão" update="@form" actionListener="#{managerRedirect.redirect('indexOrgan.xhtml')}" immediate="true"/> > 
                    <p:commandLink  value="Pesquisar" />
                </div>
            </h:form>
            <p:panel header="Pesquisar Orgão" style="width: 100%">
                <h:form id="form" acceptcharset="utf-8">
                    <p:growl id="msg" life="5000"/>
                            <fieldset style="border: 1px solid #E3E3E3; color: #3DA2DC; font-size: 13px;">
                                <legend>Filtro</legend>
                                <h:panelGrid id="fields" columns="2" style=" color: #000000; font-size: 12px; font-family: sans-serif"> 
                                    <f:validateBean disabled="true" >
                                        <p:outputLabel value="Nome :" style="float: right" />
                                        <p:inputText value="#{managerSearchOrgan.searchOrgan.name}" size="50"/>
                                        <p:outputLabel for="city" value="Cidade :" style="float: right; color: #000000;"/>
                                        <p:autoComplete size="45"  value="#{managerSearchOrgan.city}" completeMethod="#{managerCreateAddress.completeCity}"   
                                                        var="city" id="city" 
                                                        itemLabel="#{city.name} #{city.states.sgl}" itemValue="#{city}" converter="cityConverter" forceSelection="true" converterMessage="Erro, verifique a cidade" minQueryLength="3" maxResults="10" dropdown="true"> 
                                        </p:autoComplete>
                                    </f:validateBean>
                                </h:panelGrid>
                                <br/>
                                <div style="text-align:  center; margin-bottom: 15px;">
                                    <p:commandButton value="Pesquisar" icon="ui-icon-search" 
                                                     style="font-size: 12px;"
                                                     process="@form"
                                                     update="@form"/>

                                    <p:commandButton value="Cancelar" icon="ui-icon-close" actionListener="#{managerRedirect.redirect('indexOrgan.xhtml')}" style="font-size: 12px;" update="@form"/>
                                </div>
                                <p:dataTable value="#{managerSearchOrgan.search()}" var="orgao"
                                             emptyMessage="Nenhum Orgão"
                                             styleClass="dataTable" id="resultsOrgan">
                                    <f:facet name="header">
                                        <h:outputText value="Orgãos"/>
                                    </f:facet>

                                    <p:column headerText="Nome" style="font-size: 12px; width: 300px;">
                                        <h:outputText value="#{orgao.name}" style="font-size: 12px;"/>
                                    </p:column>

                                    <p:column headerText="Vara" style="font-size: 12px; width: 20%;">
                                        <h:outputText value="#{orgao.vara}" style="font-size: 12px;"/>
                                    </p:column>

                                    <p:column headerText="Cidade" style="font-size: 12px; width: 20%;">
                                        <h:outputText value="#{orgao.city.name}" style="font-size: 12px;"/>
                                    </p:column>
                                    <p:column headerText="Opções" style="font-size: 12px; width: 5%;">
                                        <p:commandButton icon="ui-icon-folder-collapsed" actionListener="#{managerEditOrgan.redirect('editOrgan.xhtml', orgao)}" title="Editar" />
                                        <p:commandButton icon="ui-icon-circle-zoomin" actionListener="#{managerSearchOrgan.redirect('showOrgan.xhtml', orgao)}" title="Visualizar Orgão" />
                                    </p:column>


                                </p:dataTable>
                            </fieldset>
                </h:form>
            </p:panel>
        </ui:define>
    </ui:composition>
</html>